﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace ExamSharedClasses
{
    [Serializable()]
    public class Class
    {
        public const string TABLENAME = "class";
        public const string CLASS_ID = "class_id";
        public const string COURSE_ID = "course_id";
        public const string CLASS_NAME = "class_name";
        public const string CLASS_BEGIN = "class_begin";
        public const string CLASS_END = "class_end";

        public int ClassId { get; set; }
        public Course Course { get; set; }
        public String ClassName { get; set; }
        public DateTime ClassBegin { get; set; }
        public DateTime ClassEnd { get; set; }

        public Class()
        {
            this.ClassId = -1;
            this.Course = new Course();
            this.ClassName = "";
            this.ClassBegin = new DateTime();
            this.ClassEnd = new DateTime();
        }
        public Class(int classId, Course course, string className, DateTime classBegin, DateTime classEnd)
        {
            this.ClassId = classId;
            this.Course = course;
            this.ClassName = className;
            this.ClassBegin = classBegin;
            this.ClassEnd = classEnd;
        }
        public Class( Class @class ) {
            this.ClassId = @class.ClassId;
            this.Course = @class.Course;
            this.ClassName = @class.ClassName;
            this.ClassBegin = @class.ClassBegin;
            this.ClassEnd = @class.ClassEnd;
        }

        public override string ToString() {
            StringBuilder sb = new StringBuilder( "Address: " );
            sb.Append( "ID: " + ClassId.ToString() + '\n' );
            if ( Course != null )
                sb.Append( Course.ToString() );
            if ( ClassName != null )
                sb.Append( "NAME: " + ClassName.ToString() + ", " );
            if ( ClassBegin != null )
                sb.Append( "BEGIN: " + ClassBegin.ToString() + ", " );
            if ( ClassEnd != null )
                sb.Append( "END: " + ClassEnd.ToString() + '\n' );
            return sb.ToString();
        }
    }
}
